package com.ruoyi.web.ydz.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.web.ydz.domain.ClinicalDisease;
import com.ruoyi.web.ydz.service.IClinicalDiseaseService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 临床招募疾病Controller
 * 
 * @author DRX
 * @date 2024-10-30
 */
@RestController
@RequestMapping("/ydz/clinicalDisease")
public class ClinicalDiseaseController extends BaseController
{
    @Autowired
    private IClinicalDiseaseService clinicalDiseaseService;

    /**
     * 查询临床招募疾病列表
     */
    @PreAuthorize("@ss.hasPermi('ydz:clinicalDisease:list')")
    @GetMapping("/list")
    public TableDataInfo list(ClinicalDisease clinicalDisease)
    {
        startPage();
        List<ClinicalDisease> list = clinicalDiseaseService.selectClinicalDiseaseList(clinicalDisease);
        return getDataTable(list);
    }

    /**
     * 导出临床招募疾病列表
     */
    @PreAuthorize("@ss.hasPermi('ydz:clinicalDisease:export')")
    @Log(title = "临床招募疾病", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ClinicalDisease clinicalDisease)
    {
        List<ClinicalDisease> list = clinicalDiseaseService.selectClinicalDiseaseList(clinicalDisease);
        ExcelUtil<ClinicalDisease> util = new ExcelUtil<ClinicalDisease>(ClinicalDisease.class);
        util.exportExcel(response, list, "临床招募疾病数据");
    }

    /**
     * 获取临床招募疾病详细信息
     */
    @PreAuthorize("@ss.hasPermi('ydz:clinicalDisease:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(clinicalDiseaseService.selectClinicalDiseaseById(id));
    }

    /**
     * 新增临床招募疾病
     */
    @PreAuthorize("@ss.hasPermi('ydz:clinicalDisease:add')")
    @Log(title = "临床招募疾病", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ClinicalDisease clinicalDisease)
    {
        return toAjax(clinicalDiseaseService.insertClinicalDisease(clinicalDisease));
    }

    /**
     * 修改临床招募疾病
     */
    @PreAuthorize("@ss.hasPermi('ydz:clinicalDisease:edit')")
    @Log(title = "临床招募疾病", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ClinicalDisease clinicalDisease)
    {
        return toAjax(clinicalDiseaseService.updateClinicalDisease(clinicalDisease));
    }

    /**
     * 删除临床招募疾病
     */
    @PreAuthorize("@ss.hasPermi('ydz:clinicalDisease:remove')")
    @Log(title = "临床招募疾病", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(clinicalDiseaseService.deleteClinicalDiseaseByIds(ids));
    }
}
